<?php
namespace  app\home\model;

use think\Model;

class Config extends Model{
    /**
     * 获取配置信息写入缓存
     */
    public function web_cache() {
        $data = $this->field('name,value')->select();
        var_dump($data);exit;
        foreach ($data as $key=>$val) {
            $val_data = $val->value;
            $web_config[$val->name] = @unserialize($val_data)?unserialize($val_data):$val_data;
        }
        var_dump($web_config);exit;
        cache('web_config', $web_config);
        return $web_config;
    }

    /**
     * 后台有更新则删除缓存
     */
    protected function _before_write($data, $options) {
        cache('web_config', NULL);
    }
}